﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using PS.Practices.SiteBuilder.Features.Schema;
using PS.Practices.Util;

namespace PS.Practices.Provisioner.Provisioner
{
    public abstract class ProvisionerAbstract
    {
        //public string Name { get; set; }
        //public string Url { get; set; }
        //public SPWebTemplate Template { get; set; }
        public string TargetWebUrl { get; set; }
        public string GalleryItemIdentifier { get; set; }
        public Dictionary<string, object> Properties { get; set; }

        private string _description = "This web was automatically provisioned.";

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        protected ProvisionerAbstract(string targetWebUrl, string galleryItemIdentifier, Dictionary<string, object> properties)
        {
            Properties = properties;
            TargetWebUrl = targetWebUrl;
            GalleryItemIdentifier = galleryItemIdentifier;

            object val = null;
            Properties.TryGetValue("Description", out val);
            if (val != null)
                Description = ParserUtil.ReplaceAllPropertyFields(val as string, Properties);
        }

        public abstract SPListItem LocateGalleryProvisionerItem(string identifier);
    }
}
